import request from '@/utils/request'

// 查询管辖资产列表
export function listAssets(query) {
  return request({
    url: '/system/assets/list',
    method: 'get',
    params: query
  })
}

// 查询管辖资产详细
export function getAssets(assetsId) {
  return request({
    url: '/system/assets/' + assetsId,
    method: 'get'
  })
}

// 新增管辖资产
export function addAssets(data) {
  return request({
    url: '/system/assets',
    method: 'post',
    data: data
  })
}

// 修改管辖资产
export function updateAssets(data) {
  return request({
    url: '/system/assets',
    method: 'put',
    data: data
  })
}

// 删除管辖资产
export function delAssets(assetsId) {
  return request({
    url: '/system/assets/' + assetsId,
    method: 'delete'
  })
}

/**
 * 批量导入资产
 * @param {FormData} data - 包含Excel文件的FormData对象
 * @returns {Promise}
 */
export function importAssets(data) {
  return request({
    url: '/system/assets/importData',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
}

/**
 * 下载资产导入模板
 * @returns {Promise}
 */
export function downloadAssetsTemplate() {
  return request({
    url: '/system/assets/downloadTemplate',
    method: 'get',
    responseType: 'blob' // 重要：指定响应类型为blob
  });
}
